<?php
$ip = getIP();
if($ip != '127.0.0.1') exit('Access Denied');
switch($do) {
	case 'reset' :
		$password = post('password');
		if($password) {
			//更新密码
			if($db->query('update systemuser set password="'.md5($password).'" WHERE username="admin"')) {
				echo "<script>
						alert('密码重置成功!');
						isIE = /msie/.test(window.navigator.userAgent.toLowerCase());
						if(isIE) {
							window.open('','_parent','');
							window.close();
						}
						else {
							document.write('设置成功,请关闭窗口!')
						}
					  </script>";
			}
			else {
				echo "<script>
						alert('密码重置失败!');
						isIE = /msie/.test(window.navigator.userAgent.toLowerCase());
						if(isIE) {
							window.open('','_parent','');
							window.close();
						}
						else {
							document.write('设置成功,请关闭窗口!')
						}
					  </script>";
			}
		}
		else{
			header("Location:index.php?mod=message&act=reset");
		}
	break;
	default :
		include template("reset");
	break;
}
?>